#include<stdio.h>
#include<stdlib.h>
void Swap(char* e1, char* e2, int widch)
{
	int i = 0;
	for (i = 0;i < widch;i++)
	{
		char tmp = *e1;
		*e1 = *e2;
		*e2 = tmp;
		e1++;
		e2++;

	}
}

int Cmp(const void* e1, const void* e2)
{
	return (*(int*)e1 - *(int*)e2);
}

void Bubble_sort(void* base, int num, int widch, int(*cmp)(const void* e1, const void* e2))
{
	int i = 0;
	for (i = 0;i < num - 1;i++)
	{
		int j = 0;
		for (j = 0;j < num - 1 - i;j++)
		{
			if (cmp((char*)base + j * widch, (char*)base + (j + 1) * widch) > 0)
			{
				Swap((char*)base + j * widch, (char*)base + (j + 1) * widch,widch);
			}
		}
	}
}





int main()
{
	int arr[10] = { 9,8,7,6,5,4,3,2,1,0 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	Bubble_sort(arr,sz,sizeof(arr[0]),Cmp);
	
	int i = 0;
	for (i = 0;i < 10;i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}